import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.border.LineBorder;
/*calls method for the next player, also 
 * checks if that player is active or not*/
public class GamebuttonUi extends JPanel {
	private BoardUi board;
	private playerPanelUi panel;
	private JButton btnEndTurn;
	
	public GamebuttonUi(BoardUi board_, playerPanelUi pui) {
		this.board=board_;
		this.panel=pui;
		
		setBorder(new LineBorder(new Color(0, 0, 0), 2));
		setBackground(new Color(210, 180, 140));
		setLayout(null);
		
		btnEndTurn = new JButton("Susunod");
		btnEndTurn.setVisible(false);
		btnEndTurn.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				board.nextPlayer();
				board.setCurrentPlayer();
				while(board.getCurrentPlayer().getActive()==false){
					board.nextPlayer();
					board.setCurrentPlayer();
				}
				board.getPlayerPanelUI().updatePlayerMoney();  //I moved it in the buy button, and pay button, but there's no harm keeping it here also
				panel.getTabbedPane().setSelectedIndex(board.getPlayerQueue());
				board.getDiceUI().enableRollBtn();
				btnEndTurn.setVisible(false);
				if(board.getCurrentPlayer().getInJail()==true){
					board.displayBlock();
				}
			}
		});
		btnEndTurn.setFont(new Font("Tahoma", Font.BOLD, 12));
		btnEndTurn.setBounds(125, 26, 89, 41);
		add(btnEndTurn);
		
		JLabel label = new JLabel("");
		label.setIcon(new ImageIcon(GamebuttonUi.class.getResource("/images/playeryellow.jpg")));
		label.setBounds(75, 11, 173, 143);
		add(label);
		
	}
	public void enableEndTurnBtn(){
		this.btnEndTurn.setVisible(true);
	}
	
	public void disableEndTurnBtn(){
		this.btnEndTurn.setVisible(false);
	}
}
